<!--
 * @Author: 吴世扬 18368095041@163.com
 * @Date: 2024-07-11 09:04:01
 * @LastEditors: 吴世扬 18368095041@163.com
 * @LastEditTime: 2024-07-26 10:06:56
 * @FilePath: /vue3-uniapp/src/components/ui/CustomNavbar/BackHomeNabbar.vue
-->
<script lang="ts" setup>
const props = withDefaults(
    defineProps<{
        fixed?: boolean;
        bgColor?: string;
        bottomShadow?: boolean;
        showBackBtn?: boolean;
        showHomeBtn?: boolean;
    }>(),
    {
        bgColor: 'transparent',
        bottomShadow: true,
        showBackBtn: true,
        showHomeBtn: true
    }
);
const { fixed, bottomShadow, bgColor, showBackBtn, showHomeBtn } =
    toRefs(props);

const goBack = () => {
    uni.$uv.route({
        type: 'back'
    });
    return false;
};

const goHome = () => {
    uni.$uv.route({
        type: 'switchTab',
        url: '/pages/tabbar/HomeView/HomeView'
    });
    return false;
};
</script>

<template>
    <TnNavbar
        :fixed="fixed || true"
        :bgColor="bgColor"
        :bottomShadow="bottomShadow"
        :back-icon="showBackBtn ? 'left' : ''"
        :home-icon="showHomeBtn ? 'home-capsule-fill' : ''"
        :before-back="goBack"
        :before-home="goHome"
    >
        <slot></slot>
    </TnNavbar>
</template>

<style lang="scss" scoped></style>
